
export default {
  init: function (AK) {
    const BMapURL = 'https://api.map.baidu.com/api?type=webgl&v=1.0&ak=' + AK + '&callback=onBMapCallback'
    return new Promise((resolve, reject) => {
      const scriptNode = document.createElement('script')
      scriptNode.setAttribute('type', 'text/javascript')
      scriptNode.setAttribute('src', BMapURL)
      document.body.appendChild(scriptNode)
      window.onBMapCallback = function () {
        console.log('百度地图脚本初始化成功...')
        resolve()
        document.body.removeChild(scriptNode)
      }
    })
  }
}